#include <iostream>
#include "skiplist.h"

using namespace std;

int main(int argc, char* argv[])
{
	int const TESTSIZE=100;
	cout<<"in skiplist test main"<<endl;

	SkipList<int, int> testSkipList(6);

	int kbuffer[TESTSIZE];
	int vbuffer[TESTSIZE];
	for(int k=0;k<TESTSIZE;++k)
	{
		kbuffer[k] = k;
		vbuffer[k] = k;
		testSkipList.doInsert(kbuffer[k], vbuffer[k], true);
		//break;
	}


	testSkipList.doPrint();

	for(int k=0;k<TESTSIZE;++k)
	//for(int k=40;k>=0;--k)
	{
		vbuffer[k] = k%50;
		testSkipList.doInsert(kbuffer[k], vbuffer[k], true);
		//testSkipList.doPrint();
		//break;
	}

	
	testSkipList.doPrint();

	//*
	int skey = 500;
	SkipListNode<int, int>* srenode = testSkipList.doSearch(skey);
	if(NULL != srenode)
	{
		cout<<endl<<endl<<"find node:("<<srenode->m_key<<","<<srenode->m_value<<")"<<endl;
	}
	else
	{
		cout<<endl<<endl<<"can not find node, when key="<<skey<<endl;
	}
	//*/
	
	int delkey = 100;
	for(int k=1;k<200;++k)
	{
		delkey = k;
		if(testSkipList.doDelete(delkey))
		{
			cout<<endl<<endl<<"succ to del :"<<delkey<<endl;
		}
		else
		{
			cout<<endl<<endl<<"fail to del :"<<delkey<<endl;
		}

		//testSkipList.doPrint();
		//break;
	}

	testSkipList.doPrint();
	return 0;
}
